package com.njitzx.util;


import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

/**
 * 密码加密工具类
 */
public class PwdUtil {

    /**
     * 加密
     *
     * @param
     * @param salt
     * @param
     * @return
     */
    public static String encrypt(String password, String salt) {

        String  combined=password+salt;
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        byte[] source = md.digest(combined.getBytes());
        return Base64.getEncoder().encodeToString(source);
    }

    /**
     * 加密
     *
     * @param
     * @return
     */
    public static String encrypt(String password) {
        return encrypt(password, "njitzx");
    }


}
